/**
 * Created by Administrator on 2017/7/6.
 */
define(function(require, exports){
	var $		= require('jquery');
	var pubjs	= require('pubjs');
	var view	= require('@base/view');
	var util	= require('util');
	// 账户
	var account = view.container.extend({
		init:function(config){
			config = pubjs.conf(config, {
				'class': 'P-overview'
			});
			this.Super('init', arguments);
		},
		afterBuild:function(){
			this.append($([
				'<div class="M-formHead">',
				'<span class="M-formHeadTitle">'+LANG('')+'</span>',
				'<span class="fr" pub-name="date" pub-mod="@base/common/date.dateRangeNew"/>',
				'</div>',
				'<div class="cl" pub-name="grid" pub-mod="report/grid/summary/list.accountlGrid"/>'
			].join('')));

			var c = this.getConfig();

			this.buildFromTemplate({
				'date': {
					'pos': 'bR',
					'userStorage': false
				},
				'grid': {
					'auto_load': true,
					// 'param': {
					// 	'begindate': util.today(),
					// 	'enddate': util.todayEnd()
					// },
					'userStorageDate': false,
					'hasSearch': true,
					'gridName': 'overview_channel',
					'hasFilterSidebar': true,
					'sidebar_config': {
						'items': [
							{'name': 'Status', 'uri':'modules/sideBarBase.radio', 'config': {
								'title': LANG('状态：'),
								'data': [
									{id: 0, name: LANG('所有投放')},
									{id: 1, name: LANG('投放')},
									{id: 2, name: LANG('停用')}
								]
								,value:0
							}},
						]
					}
				}
			});
		},
		reload: function(param){
			this.$.grid.reload(param);
		},
		onSidebarFilter: function(ev){
			var self = this
				,param = {};

			util.each(ev.param, function(item, idx){
				var type = idx;
				var id = item.id;

				switch (type) {
					case 'Status':
						param.status = +id;
						break;
				}
			});

			self.$.grid.reload(param);
		}
	});
	exports.account = account;
	// 广告主
	var adver = view.container.extend({
		init:function(config){
			config = pubjs.conf(config, {
				'class': 'P-overview'
			});
			this.Super('init', arguments);
		},
		afterBuild:function(){
			this.append($([
				'<div class="M-formHead">',
				'<span class="M-formHeadTitle">'+LANG('')+'</span>',
				'<span class="fr" pub-name="date" pub-mod="@base/common/date.dateRangeNew"/>',
				'</div>',
				'<div class="cl" pub-name="grid" pub-mod="report/grid/summary/list.adverGrid"/>'
			].join('')));

			var c = this.getConfig();

			this.buildFromTemplate({
				'date': {
					'pos': 'bR',
					'userStorage': false
				},
				'grid': {
					'auto_load': true,
					// 'param': {
					// 	'begindate': util.today(),
					// 	'enddate': util.todayEnd()
					// },
					'userStorageDate': false,
					'hasSearch': true,
					'gridName': 'overview_channel',
					'hasFilterSidebar': true,
					'sidebar_config': {
						'items': [
							{'name': 'IsDeleted', 'uri':'modules/sideBarBase.radio', 'config': {
								'title': LANG('状态：'),
								'data': [
									{id: 0, name: LANG('有效')},
									{id: 1, name: LANG('归档')}
								]
								,value: 0
							}},
						]
					}
				}
			});
		},
		reload: function(param){
			this.$.grid.reload(param);
		},
		onSidebarFilter: function(ev){
			var self = this
				,param = {};

			util.each(ev.param, function(item, idx){
				var type = idx;
				var id = item.id;

				switch (type) {
					case 'IsDeleted':
						param.IsDeleted = +id;
						break;
				}
			});
			self.$.grid.reload(param);
		}
	});
	exports.adver = adver;
});